/*
 * iron_tips.cpp
 *
 *  Created on: 15 aug. 2019.
 *      Author: Alex
 */

#include "iron_tips.h"
#include "eeprom.h"
#include "string.h"

static char tip_names[][tip_name_sz] = {
		{'H', 'O',  'G',  'U',   'N'},		// The Hot Air Gun is just another virtual tip that has its own calibration. It should be on the top of list!!!
		{'B', '\0', '\0', '\0', '\0'},
		{'B', '1',  '\0', '\0', '\0'},
		{'B', '2',  '\0', '\0', '\0'},
		{'B', '3',  '\0', '\0', '\0'},
		{'B', '4',  '\0', '\0', '\0'},
		{'B', '2',  'Z',  '\0', '\0'},
		{'B', 'C',  '1',  '\0', '\0'},
		{'B', 'C',  '1',  '.' ,  '5'},
		{'B', 'C',  '2',  '\0', '\0'},
		{'B', 'C',  '3',  '\0', '\0'},
		{'B', 'C',  '1',  'Z',  '\0'},
		{'B', 'C',  '2',  'Z',  '\0'},
		{'B', 'C',  '4',  'Z',  '\0'},
		{'B', 'C',  'F',  '1',  '\0'},
		{'B', 'C',  'F',  '2',  '\0'},
		{'B', 'C',  'F',  '3',  '\0'},
		{'B', 'C',  'F',  '4',  '\0'},
		{'B', 'C',  'F',  '1',   'Z'},
		{'B', 'C',  'F',  '2',   'Z'},
		{'B', 'C',  'F',  '3',   'Z'},
		{'B', 'C',  'M',  '2',  '\0'},
		{'B', 'C',  'M',  '3',  '\0'},
		{'B', 'L', '\0', '\0',  '\0'},
		{'B', 'Z', '\0', '\0',  '\0'},
		{'C', '1', '\0', '\0',  '\0'},
		{'C', '2', '\0', '\0',  '\0'},
		{'C', '3', '\0', '\0',  '\0'},
		{'C', '4', '\0', '\0',  '\0'},
		{'D', '0',  '8', '\0',  '\0'},
		{'D', '1',  '2', '\0',  '\0'},
		{'D', '1',  '6', '\0',  '\0'},
		{'D', '2',  '4', '\0',  '\0'},
		{'D', '3',  '2', '\0',  '\0'},		// Tip added 04/01/2022
		{'D', '5',  '2', '\0',  '\0'},
		{'D', '4', '\0', '\0',  '\0'},
		{'D', 'L',  '1',  '2',  '\0'},
		{'D', 'L',  '3',  '2',  '\0'},
		{'D', 'L',  '5',  '2',  '\0'},
		{'D', '1',  '2',  'Z',  '\0'},
		{'D', '2',  '4',  'Z',  '\0'},
		{'D', '4',  'Z', '\0',  '\0'},
		{'I', '\0', '\0', '\0', '\0'},
		{'I',  'L', '\0', '\0', '\0'},
		{'I',  'L',  'S', '\0', '\0'},
		{'J',  '0',  '2', '\0', '\0'},
		{'J',  'L',  '0',  '2', '\0'},
		{'J',  'S',  '0',  '2', '\0'},
		{'K', '\0', '\0', '\0', '\0'},
		{'K',  'F', '\0', '\0', '\0'},
		{'K',  'L', '\0', '\0', '\0'},
		{'K',  'R', '\0', '\0', '\0'},
		{'K',  'F',  'Z', '\0', '\0'},
		{'K',  'R',  'Z', '\0', '\0'},
		{'K',  'U', '\0', '\0', '\0'},		// Tip added 09/12/2018
		{'W',  'B',  '2', '\0', '\0'},
		{'W',  'D',  '0',  '8', '\0'},
		{'W',  'D',  '1',  '2', '\0'},
		{'W',  'D',  '1',  '6', '\0'},
		{'W',  'D',  '5',  '2', '\0'},
		{'W',  'I', '\0', '\0', '\0'},
		{'N',  '1',  '-',  '0',  '6'},
		{'N',  '1',  '-',  '0',  '8'},
		{'N',  '1',  '-',  '1',  '0'},
		{'N',  '1',  '-',  '1',  '3'},
		{'N',  '1',  '-',  '1',  '6'},
		{'N',  '1',  '-',  '2',  '0'},
		{'N',  '1',  '-',  '2',  '3'},
		{'N',  '1',  '-',  'L',  '1'},
		{'1',  '0',  '0',  '1', '\0'},
		{'1',  '0',  '0',  '2', '\0'},
		{'1',  '0',  '0',  '3', '\0'},
		{'1',  '0',  '0',  '4', '\0'},
		{'1',  '0',  '0',  '5', '\0'},
		{'1',  '0',  '0',  '6', '\0'},
		{'1',  '0',  '0',  '7', '\0'},
		{'1',  '0',  '0',  '8', '\0'},
		{'1',  '0',  '0',  '9', '\0'},
		{'1',  '0',  '1',  '0', '\0'},
		{'1',  '2',  '0',  '1', '\0'},
		{'1',  '2',  '0',  '2', '\0'},
		{'1',  '2',  '0',  '3', '\0'},
		{'1',  '2',  '0',  '4', '\0'},
		{'1',  '2',  '0',  '5', '\0'},
		{'1',  '2',  '0',  '6', '\0'},
		{'1',  '2',  '0',  '7', '\0'},
		{'1',  '2',  '0',  '8', '\0'},
		{'1',  '2',  '0',  '9', '\0'},
		{'1',  '4',  '0',  '1', '\0'},
		{'1',  '4',  '0',  '2', '\0'},
		{'1',  '4',  '0',  '3', '\0'},
		{'1',  '4',  '0',  '4', '\0'},
		{'1',  '4',  '0',  '5', '\0'},
		{'1',  '4',  '0',  '6', '\0'}
};

static uint16_t tip_number	= sizeof(tip_names) / tip_name_sz;

uint16_t TIPS::loaded(void) {
	return tip_number;
}

const char* TIPS::name(uint8_t index) {
	if (index < tip_number) {
		return tip_names[index];
	}
	return 0;
}

int TIPS::index(const char *name) {
	for (uint16_t i = 0; i < tip_number; ++i) {
		if (strncmp(name, tip_names[i], tip_name_sz) == 0)
			return i;
	}
	return -1;
}
